package main.module.desktop
{
	import com.standlibrary.debug.Debug;
	import com.standlibrary.load.GetObject;
	
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	import main.manager.SenceManger;
	import main.manager.UIManager;

	/**
	 * 
	 * @author bianbo
	 */
	public class DesktopUI
	{

		private static var bool:Boolean = true;
		private static var myinstance:DesktopUI;
		
		private var topUI:MovieClip;
		
		public function DesktopUI()
		{
			if(bool)
				throw new Error("single instance");
		}
		
		public static function get instance():DesktopUI
		{
			if(myinstance == null)
			{
				bool = false;
				myinstance = new DesktopUI();
				bool = true;
			}
			
			return myinstance;
		}
		
		public function init():void
		{
			topUI = GetObject.getMC("UI_Top");
			topUI.packageBt.addEventListener(MouseEvent.CLICK, uiBtClick);
			topUI.mailBt.addEventListener(MouseEvent.CLICK, uiBtClick);
			topUI.syssetBt.addEventListener(MouseEvent.CLICK, uiBtClick);
			topUI.returnBt.addEventListener(MouseEvent.CLICK, uiBtClick);
			
			UIManager.instance.main.addChild(topUI);
		}
		
		
		private function uiBtClick(eve:MouseEvent):void
		{
			var nameStr:String = eve.target.name;
			
			switch(nameStr)
			{
				case "packageBt":
					break;
				case "mailBt":
					break;
				case "syssetBt":
					break;
				case "returnBt":
					SenceManger.instance.changeSence();
					break;
			}
			Debug.log(nameStr);
		}
	}
}